import React, {Component} from 'react'

import Title from './Components/Title'
import StudentLeftList from './Components/StudentLeftList'
import StudentRighrList from './Components/StudentRighrList'
class App extends Component {
  state = {
    studentList:[]
  }
  addList = (student,callback) => {
    this.setState({
      studentList:[...this.state.studentList,student]
    },() => {
      callback();
    })
  }
  removeList = (number) => {
    const studentList = JSON.parse(JSON.stringify(this.state.studentList))
    const index = studentList.findIndex(item => item.number = number)
    studentList.splice(index,1)
    this.setState({
      studentList:studentList
    },()=>{
      console.log(this.state.studentList);
    })
  
  }
  render() {
    return (
      <div className={'container'}>
        <Title></Title>
        <StudentLeftList addList={this.addList}></StudentLeftList>
        <StudentRighrList studentList={this.state.studentList} removeList={this.removeList}></StudentRighrList>
      </div>
    );
  }
}

export default App;
